package com.gaofei.goods.controller;

import com.gaofei.goods.openfeign.UserFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author : gaofee
 * @date : 11:52 2021/5/18
 * @码云地址 : https://gitee.com/itgaofee
 */
@RequestMapping("goods")
@RestController
public class GoodsController {

    @Autowired
    UserFeignClient userFeignClient;

    @Autowired
    RestTemplate restTemplate;

    @RequestMapping("list")
    public String list(String id){
        return "这是商品服务!!===>"+userFeignClient.hello(id);
    }

    //restTemplate实现远程调用
    @RequestMapping("list2Rest")
    public String list2Rest(String id){
        String forObject = restTemplate.getForObject("http://127.0.0.1:8180/user/hello/2", String.class);
        return "这是商品服务!!===>"+forObject;
    }
}
